package com.sist.ocs.mqcallback;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;

/**
 * @ClassName MsgSendConfirmCallBack
 * @Description TODO
 * @Author: xmk
 * @Date: 2018/10/25 16:53
 * @Version: 1.0
 */
public class MsgSendConfirmCallBack implements RabbitTemplate.ConfirmCallback {
    /**
     *
     * @param correlationData
     * @param b 未成功发送消息到交换器（如交换器不存在），才false，否则true
     * @param s 失败时的信息
     */
    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {
        System.out.println("MsgSendConfirmCallBack  , 回调id:" + correlationData.getId());
        if (b) {
            System.out.println("消息发送成功" + s);
        } else {
            System.out.println("消息发送失败:" + s + "\n重新发送");
        }
    }
}
